package os;
import memory.*;
/**
 *
 * @author Paulius Dambrauskas
 */
class StartFromVm extends Process {
    @Override
    public void runProcess() {
        this.changeStepCell(step);
        switch(step){
            case 1:{
                //changeStepCell(1);
                OS.askRes("Paleidimas iš VM", selfId);
                incStep(1);
                break;
            }
            case 2:{
                //changeStepCell(2);
                int fileNameBlock = Integer.parseInt((String)this.takeFromGivenResources("Paleidimas iš VM").value);
                String input = "";
                //Programos pavadinimas
                int j = 0;
                String word = Memory.getByAddress(fileNameBlock);
                while (!word.startsWith("$")){
                    input += word;
                    fileNameBlock++;
                    word = Memory.getByAddress(fileNameBlock);
                    j++;
                }
                input +=" :";
                //Parametrai
                int parmBlock = fileNameBlock+1;
                while (j < 16){
                    word = Memory.getByAddress(parmBlock);
                    input += " "+word;
                    j++;
                    parmBlock++;
                }
                OS.freeRes(new ResourceElement("Įvestis", input));
                setStep(1);
                break;
            }
        }
    }
    
}
